// includes, system
#include "aithin_cuda.h"

__global__ void seek_embryos(int* neurons,
							 int neurons_count,
							 cuEmbryo* embryos, 
							 int embryos_count )
{

	int i = blockIdx.x * blockDim.x + threadIdx.x;

	int m = 1;

	if (i < embryos_count )
	{
		for (int j = 0; j < neurons_count; j++)
		{
			for(int k = 0; k < embryos[i].inputs_count; k++)
				if(embryos[i].connections[k] == neurons[j] ) m++;
		}

		if (0.7f < (float) m/(float) embryos[i].inputs_count)
			embryos[i].was_activ= embryos[i].was_activ++;
	}
}

 void checkCUDAError(const char *msg)
{
    cudaError_t err = cudaGetLastError();
    if( cudaSuccess != err) 
    {
        fprintf(stdout, "Cuda error: %s: %s.\n", msg, 
                             cudaGetErrorString( err) );
        exit((int)err);
    }                         
}
